/*
 * Copyright (C) 2022 Positec.
 *
 * 
 * Author:
 *         Xi.Huang@positecgroup.com
 *
 *    1. Init version 03/20/23.
 */

#ifndef _TIMESYNC_CLIENT_UAPI_H_
#define _TIMESYNC_CLIENT_UAPI_H_

#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <linux/rtc.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <stddef.h>
#include <pthread.h>
#include <stdint.h>


#ifdef __cplusplus
extern "C" {
#endif





/*
 * brief:       Check the str is or not a digital string.
 * parameters:  @str: Input string.
 * @return   :  0, is not a digital string; 1, is a digital string.
 *
 */
int isdigitstr(char *str);


/*
 * brief:
 *       Init the pps client, init network attributes.
 *
 * @server_ip:
 *             IP address of pps server.
 * @client_ip: IP address of pps client.
 *
 * @server_port:
 *             server process port.
 * @client_port:
 *             client process port. 
 *
 * @return:
 *         0, init successful; nozero, init failed.           
 * 
 */
int timesync_client_init(const char *server_ip, const char *client_ip, const uint16_t server_port, const uint16_t client_port);


/*
 * brief:
 *          Get the ACK of time sync.
 * @parameters:
 *          None.
 * @return:
 *          0, time sync setting successful of client; nozero, time sync failed.
 *
 */
int timesync_client_time_sync_ack_get(void);


/*
 * brief:
 *          Enable time sync pulse signal to sensor.
 * @enable:
 *          A enablie bit. nozero, enable pulse output; 0, disable pulse output.
 * @pulse_number:
 *          Numbers of pulse output.
 * @return:
 *          0, successful, nozero failed.
 *
 */
int timesync_sync_pulse_output_enable(int enable, int pulse_number);

















#ifdef __cplusplus
}
#endif
#endif /* _TIMESYNC_CLIENT_UAPI_H_*/
